<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            background-color: pink;
        }
    </style>
</head>

<body>
    <div id="test"></div>

    <!-- 引入核心库 -->
    <script type="text/javascript" src="./React-js/16.8/react.development.js"></script>
    <!-- 用于支持react操作DOM -->
    <script text="text/javascript" src="./React-js/16.8/react-dom.development.js"></script>
    <!-- 用于将jsx转换为js -->
    <script text="text/javascript" src="./React-js/16.8/babel.min.js"></script>

    <script type="text/babel">
        // 定义类组件
        class Weather extends React.Component {
            // 构造器是否接受props，是否传递super，取决于：是否需要在构造器中通过this访问props
            // 若是写了构造器，不给super传props则，在构造器中拿不到props。为undefined
            constructor(props) {    // 构造器只调用一次 
                // super(props)
                super()
                console.log(this.props);
            }
            render() {
                return (
                    <h2 ></h2>
                )
            }
        }

        const p = { name: 'tom', age: 18, sex: '女' }
        // 渲染组件到页面
        ReactDOM.render(<Weather {...p} />, document.getElementById('test'))
    </script>
</body>

</html>